<?php
/**
 * Simple Light PHP Framework
 *
 * @copyright Marc PEPIN 2012
 * @author Marc PEPIN
 *
 */

defined('SLP_ROOT') or die("You've not access to this page");

/**
 * Simple Light Php Framework Application Template Class
 *
 * This class is used to render html files
 *
 * @package             Slp
 * @author              Marc PEPIN
 */

class Slp_Template {
	
	/**
	* Template name
	* @var string
	*/
	
	private $tpl;
	
	
	/**
	* Variables to export in template
	* @var array
	*/
	
	private $vars;


	/**
	* Constructor
	* @param string
	*/
	
	public function __construct($tpl) {
			$this->vars = array();
			$this->tpl = $tpl;
	}

	/**
	* Assign data to template
	* @param array 
	*/
	
	public function assign($vars) {
			$this->vars[] = $vars;
	}


	/**
	* Render template
	*/
	
	public function render() {
			if ($this->vars) {
				foreach ($this->vars as $vars) 
					extract($vars);
			}
			extract($GLOBALS, EXTR_SKIP);
			ob_start();
			require(SLP_ROOT.'/application/templates/'.$this->tpl.'.tpl.php');
			$applied_template = ob_get_contents();
			ob_end_clean();
			return $applied_template;
	}
}

?>